#ifndef __regex_chunk_hpp
#define __regex_chunk_hpp
#include "bRegex.h"
#include "bObject.h"
#include "bReference.h"
#include "bArray.h"
#include "bString.h"

namespace Regex
{
	class Chunk;
	class GroupChunk;
	class CharClassChunk;
	class TerminateChunk;
	class ConstChunk;
	class Repetition;
	class Regex;//Declare that such a class exists, because we reference it.

	class Repetition:public bObject
	{
	protected:
		 unsigned long int _min,_max;
	public:
		Repetition(const char*);
		const unsigned long int min() const;
		const unsigned long int max() const;
		virtual ~Repetition();
	};

	class Chunk:public bObject
	{
	private:
		static unsigned long int gID;
	protected:
		bReference<Repetition> modifier;
		const unsigned long int mID;
	public:
		Chunk();
		Chunk* modify(Repetition*);
		virtual unsigned long int operator () (const char*,unsigned long int) const = 0;
		virtual ~Chunk();
	};

	class TerminateChunk:public Chunk
	{
	public:
		unsigned long int operator () (const char*,unsigned long int) const;
	};

	class GroupChunk:public Chunk
	{
	protected:
		bReference<Regex> comp;
	public:
		virtual ~GroupChunk();
		GroupChunk(const char*,unsigned long int);
		unsigned long int operator () (const char*,unsigned long int) const;
	};

	class ConstChunk:public Chunk
	{
	protected:
		bString comp;
	public:
		ConstChunk(const char*,unsigned long int);
		unsigned long int operator () (const char*,unsigned long int) const;
	};

	class CharClassChunk:public Chunk
	{
		bReference<bString> chars;
		bool include;
	public:
		CharClassChunk(const char*,unsigned long int);
		unsigned long int operator () (const char*,unsigned long int) const;
	};
}
#endif